<template>
  <div class="block">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="searchParams.page + 1"
      :page-sizes="pages"
      :page-size="searchParams.limit"
      layout="total, sizes, prev, pager, next"
      :total="count"
      background
    >
    </el-pagination>
  </div>
</template>
<script>
export default {
  props: {
    data: {
      type: Array,
      default: () => []
    },
    count: {
      type: Number,
      default: 0
    },
    searchParams: {
      type: Object,
      default: null
    },
    pages: {
      type: Array,
      default: [15, 18, 21, 24, 27, 30]
    }
  },
  methods: {
    // 调整每页展示数
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.searchParams.limit = val;
      this.$emit("doSearch", this.searchParams);
    },
    // 换页
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      console.log("pre");
      this.searchParams.page = val - 1;
      this.$emit("doSearch", this.searchParams);
    }
  },
  mounted() {
  }
};
</script>
